package com.hhxy.request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;

/**
 * 使用Request对象获取请求体数据
 */
@WebServlet("/req3")
public class RequestDemo3 extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1、获取Post请求的请求参数
        //1.1 获取字符输入流
        BufferedReader br = req.getReader();
        //1.2 读取数据
        String requestData = br.readLine();
        System.out.println(requestData);//输出：
    }
}
